package o;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import com.huawei.appmarket.service.activitydispatcher.OpenGateway;
import com.huawei.appmarket.service.activitydispatcher.OpenGateway$c;
import org.json.JSONArray;
import org.json.JSONException;

public class eeu implements cue<cuk> {
    public /* synthetic */ void ˋ(Context context, Object obj) {
        ˊ(context, (cuk) obj);
    }

    public void ˊ(Context context, cuk o_cuk) {
        Logger.ˎ("SelfDefineHandler", "SelfDefineHandler execute");
        if (o_cuk != null) {
            String ॱॱ = o_cuk.ॱॱ();
            if (ॱॱ != null && "activity".equals(ॱॱ)) {
                ॱॱ = o_cuk.ˊˋ();
                Object ˋˊ = o_cuk.ˋˊ();
                if (!TextUtils.isEmpty(ˋˊ)) {
                    try {
                        OpenGateway$c ˎ = OpenGateway.ˎ(ॱॱ, new JSONArray(ˋˊ), false);
                        if (ˎ == null) {
                            Logger.e("SelfDefineHandler", "activity is null");
                        } else if (ˎ.ˎ() != null) {
                            cjm ˎ2 = ˎ.ˎ();
                            if (!(context instanceof Activity)) {
                                ˎ2.ॱ().addFlags(268435456);
                            }
                            cjk.ˎ().ˋ(context, ˎ2);
                        } else if (ˎ.ˏ() != null) {
                            if (!(context instanceof Activity)) {
                                ˎ.ˏ().addFlags(268435456);
                            }
                            context.startActivity(ˎ.ˏ());
                        } else if (ˎ.ˊ() != null) {
                            ˊ(context, ˎ);
                        } else {
                            Logger.e("SelfDefineHandler", "can not start target activity.Go MainActivity");
                        }
                    } catch (JSONException e) {
                        Logger.ˎ("SelfDefineHandler", "ActivityParams error, JSON Exception : " + e.toString());
                    }
                }
            }
        }
    }

    private void ˊ(Context context, OpenGateway$c openGateway$c) {
        Intent intent = openGateway$c.ˊ().ˏ;
        if (intent != null) {
            if (!(context instanceof Activity)) {
                intent.addFlags(268435456);
            }
            fiu.ˊ().ॱ(context, openGateway$c.ˊ().ˋ, intent);
        }
    }
}
